<#include "/jsp/common/head.html">

<div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>用户管理页面 >> 用户添加页面</span>
        </div>
        <div class="providerAdd">
        ${message!}
            <form id="userForm" name="userForm" method="post" enctype="multipart/form-data" action="${request.contextPath }/jsp/useradd.do">
			    <!--div的class 为error是验证错误，ok是验证成功-->
                <div>
                    <label for="userCode">用户编码：</label>
                    <input type="text" name="userCode" id="userCode" value=""> 
					<!-- 放置提示信息 -->
					<font color="red"></font>
                </div>
                <div>
                    <label for="userCode">用户头像：</label>
                    <input type="file" name="attach1" id="attach1" value=""> 
					<!-- 放置提示信息 -->
					<font color="red" id="tips"></font>
                    <input type="button" id="upload" name="upload" value="上传"  onclick="upladFileJ('attach1','tips');">
                </div>                
                <div>
                    <label for="userName">用户名称：</label>
                    <input type="text" name="userName" id="userName" value=""> 
					<font color="red"></font>
                </div>
                <div>
                    <label for="userPassword">用户密码：</label>
                    <input type="password" name="userPassword" id="userPassword" value=""> 
					<font color="red"></font>
                </div>
                <div>
                    <label for="ruserPassword">确认密码：</label>
                    <input type="password" name="ruserPassword" id="ruserPassword" value=""> 
					<font color="red"></font>
                </div>
                <div>
                    <label >用户性别：</label>
					<select name="gender" id="gender">
					    <option value="1" selected="selected">男</option>
					    <option value="2">女</option>
					 </select>
                </div>
                <div>
                    <label for="birthday">出生日期：</label>
                    <input type="text" Class="Wdate" id="birthday" name="birthday" 
					onclick="WdatePicker();">
					<font color="red"></font>
                </div>
                <div>
                    <label for="phone">用户电话：</label>
                    <input type="text" name="phone" id="phone" value=""> 
					<font color="red"></font>
                </div>
                <div>
                    <label for="address">用户地址：</label>
                   <input name="address" id="address"  value="">
                </div>
                <div>
                    <label >用户角色：</label>
                    <!-- 列出所有的角色分类 -->
					<select name="userRole" id="userRole"></select>
	        		<font color="red"></font>
                </div>
                <div class="providerAddBtn">
                    <input type="submit" name="add" id="add" value="保存" >
					<input type="button" id="back" name="back" value="返回" >
                </div>
            </form>
        </div>
</div>
</section>
<#include "/jsp/common/foot.html">
<script type="text/javascript">
    function upladFile(file, tips) {
        // 获取文件对象
        var fileObj = document.getElementById(file);
        // H5 FormData 对象
        var form = new FormData();
        form.append(file, fileObj.files[0]); // 文件对象
        // XMLHttpRequest 对象
        var xhr = new XMLHttpRequest();
        xhr.open("post", "uploadAjax");
        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4	&& xhr.status == 200) {
                //获取代理反馈的信息
                document.getElementById(tips).innerHTML = xhr.responseText;
            }
        };
        xhr.send(form);
    }
    function upladFileJ(file, tips) {
        // H5 FormData 对象
        var form = new FormData();
        form.append(file, $('#'+file).get(0).files[0]);
        $.ajax({url : "uploadAjax", type : "post",
            data : form, processData : false, contentType : false,
            success: function (data) {
                $('#'+tips).html(data);
            }});
    }
</script>